moduleAplicacao.factory('securityService', function($http) {
	return {
		getUsuario : function(callback){
			$http.get('rest/security/getUserSession').success(function(user){
				if(callback){
					callback(user);
				}
			});
		},
		
		getModulos : function(callback){
			$http.get('proxy/security/sessao/listarModulos', {
				params : {
					chave: window.usuario.chave
				}
			}).success(function(modulos){
				if(callback){
                                    callback(modulos);
				}
			});
		},
		
		getLayers : function(callback){
			$http.get('proxy/security/sessao/listarLayers', {
				params : {
					chave: window.usuario.chave
				}
			}).success(function(layers){
				if(callback){
					callback(layers);
				}
			});
		},
		
		getBaseLayers : function(callback){
			$http.get('proxy/security/sessao/listarBaseLayers', {
				params : {
					chave: window.usuario.chave
				}
			}).success(function(baseLayers){
				if(callback){
					callback(baseLayers);
				}
			});
		},
		
		logout : function(callback){
			$http.post('rest/security/logout').success(function(sucesso){
				if(callback){
					callback(eval(sucesso));
				}
			});
		},
		
		keepAlive : function(callback){
			$http.post('rest/security/keepAlive').success(function(success){
				if(callback){
					callback(success);
				}
			});
		}
	};
});